<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:a="https://ajax4jsf.dev.java.net/ajax"
	xmlns:rich="http://richfaces.ajax4jsf.org/rich"
	xmlns:ctg="http://www.crotouristguide.com/taglib"
	template="/templates/layout/columns_4.xhtml"
	xmlns:c="http://java.sun.com/jstl/core">
	<ui:define name="column1">
		<ctg:status/>
		<s:div styleClass="title"><h1>
				#{messages['title.map.search']}</h1>
				#{messages['subtitle.map.search']}</s:div>
		
		<h:form id="form"> 
			<h:panelGrid columns="3" id="mapSearch">
				<s:decorate id="tipObjektaDecoration"
					template="/templates/displayOneRow.xhtml">
					<ui:define name="label">#{messages['label.object.type']}</ui:define>
					<h:selectOneMenu id="tipObjekta" styleClass="field"
						value="#{searchParameters.tipObjektaMap}">
						<s:selectItems var="to" value="#{tipoviObjekata}"
							label="#{messages[stringUtil.merge(to.idTipaObjekta)]}"></s:selectItems>
							<s:convertEntity/>	
					</h:selectOneMenu>
				</s:decorate>
				<s:decorate template="/templates/editOneRow.xhtml">
					<ui:define name="label">
						<h:outputText value="#{messages['label.destination']}:" />
					</ui:define>
					<h:selectOneMenu styleClass="field"
								value="#{searchParameters.mjestoMap}">
								<s:selectItems id="zupanije" value="#{mjestaByObjekti}"
									var="m" label="#{m.naziv}"
									noSelectionLabel="#{messages['label.choose']}" />
									<s:convertEntity/>	
								</h:selectOneMenu>
				</s:decorate>
				<h:commandButton value="#{messages['label.search']}">
					<s:conversationPropagation type="none"></s:conversationPropagation>
				</h:commandButton>
			</h:panelGrid>
		</h:form>
		<br />
		<ctg:googleMaps gmapVar="map" width="940"
			height="700"
			largeMapControl="true" mapTypeControl="true" scaleControl="true"
			overviewMapControl="true" lat="44.5"
			lng="16.50" zoom="7"/>
		<script type="text/javascript">
			function loadMap(map){	
		  	    <ui:repeat value="#{googleMapsAction.getSearchResults()}" var="ob">
	   	    	<c:set var="tempAdr" value="#{ob.getAdresa(1)}"></c:set>
	   	    	<c:when test="#{tempAdr != null}">
	   	    		<c:set var="adresa" value="#{tempAdr.ulica} #{tempAdr.broj}, #{tempAdr.mjesto.naziv}"></c:set>
	   	    	</c:when>
		   	    	<f:subview rendered="#{ob.longituda != null}">
		   	 		setMarkerWithIcon(map, #{ob.longituda},#{ob.latituda},'green',"#{messages[stringUtil.toString(ob.tipObjekta.idTipaObjekta)]} #{ob.naziv}&lt;br/&gt;#{adresa}&lt;br/&gt;&lt;a href='#{application.contextPath}/guides/objekti/objekt.seam?idObjekta=#{ob.idObjekta}&amp;l=#{currentLang}&amp;title=#{titleAction.getUrlTitle(ob)}' class='text11'&gt;#{messages['message.click_for_details']}&lt;/a&gt;");
					</f:subview>
			    </ui:repeat>			
			}
		</script>
	</ui:define>
</ui:composition>